import { ArgumentsHost, Catch, ExceptionFilter, HttpException } from '@nestjs/common'
import { Response } from 'express'

// @Catch 来指定要处理的异常类型
@Catch(HttpException)
export class TestFilter implements ExceptionFilter {
   catch(exception: HttpException, host: ArgumentsHost) {
      const res: Response = host.switchToHttp().getResponse()
      res.status(exception.getStatus()).json({
         msg: exception.message
      })
   }
}
